/*
 * @Description: 
 * @Author: mmzhang
 * @Date: 2021-11-15 14:38:47
 * @LastEditTime: 2023-01-09 15:01:33
 */
import customerApi from '@/config/server/api/customer.js'
import dt from '@dt/dt'

let codes = {
  '认购审核': '0113010000',//[8]
  '签约审核': '0113020000',//[9]
  '回款审核': '0113030000', //[10]
  '附件审核': '0113040000',//[14, 15]
  '客户批注': '0113050000',//[12, 13]
  '案场状态维护': '0113060000',//[16]
  '营销信息维护': '0113070000',//[17, 18]
  '霸屏神器维护': '0113090000',//[20]
  '人员异动维护': '0113100000',//[21, 22]
  '线索分配': '0113120000', // [23]
  '目标设定':'0113130000',//[36,38,39,40]  36 线索 38来人  39 认购  40 签约
  '案场日报维护':'0113140000', //[35]
  '退购单审核':'0113150000',//[25]
  '退签单审核':'0113160000',//[26]
  '请佣单确认':'0113170000',//[27]
  '请佣单附件上传及时（甲方签收发票回执）':'0113180000',//[28]
  '请佣单附件上传及时（甲方盖章附件）':'0113320000',//[29]
  '佣金回款附件上传及时（银行回单附件）':'0113190000',//[30]
  '请佣单回款核销任务':'0113200000',//[32]
  '我司盖章附件上传':'0113210000',//[31]
  '线上售楼处审核':'0113220000',//[34]
  '置业计划书素材审核':'0113230000',//[33]
  '非特殊奖金单审核':'0113240000',//[101]
  '非特殊奖金单截止日期审核':'0113280000',//[102]
  '在销激励审核':'0113250000',//[103]
  '在销激励截止日期审核':'0113290000',//[104]
  '项目津贴审核':'0113260000',//[105]
  '项目津贴截止日期审核':'0113300000',//[106]
  '特殊奖金审核':'0113270000',//[107]
  '特殊奖金截止日期审核':'0113310000'//[108]
}

function getLeftTaskCount(info) {
  return customerApi.task.leftTaskCount.fetch(info).then(res => {
    return res.filter(item => {
      let code = codes[item.taskName]
      return !code || dt.unlocking(code)
    })
  })
}


function taskCount(info) {

  return customerApi.task.taskCount.fetch(info).then(res => {
    return res
  })
}


function getTaskList(info) {
  return customerApi.task.taskList.fetch(info).then(res => {
    return res
  })
}

function getTopTaskStatusCount(info) {
  return customerApi.task.topTaskStatusCount.fetch(info).then(res => {
    return res
  })
}

function getTaskMsgTips(info) {
  return customerApi.task.taskMsgTips.fetch(info).then(res => {
    return res
  })
}

// 案场内
function getLeftTaskCountWithBuildingId(info) {
  return customerApi.task.leftTaskCountWithBuildingId.fetch(info).then(res => {
    return res.filter(item => {
      let code = codes[item.taskName]
      return !code || dt.unlocking(code)
    })
  })
}

function getTaskListWithBuildingId(info) {
  return customerApi.task.taskListWithBuildingId.fetch(info).then(res => {
    return res
  })
}

function getTopTaskStatusCountWithBuildingId(info) {
  return customerApi.task.topTaskStatusCountWithBuildingId.fetch(info).then(res => {
    return res
  })
}

// 工作台
function getLeftTaskCountWithOrg(info) {
  return customerApi.work.leftTaskCountWithOrg.fetch(info).then(res => {
    return res.filter(item => {
      let code = codes[item.taskName]
      return !code || dt.unlocking(code)
    })
  })
}

function getTaskListWithOrg(info) {
  return customerApi.work.taskListWithOrg.fetch(info).then(res => {
    return res
  })
}

function getTopTaskStatusCountWithOrg(info) {
  return customerApi.work.topTaskStatusCountWithOrg.fetch(info).then(res => {
    return res
  })
}

export default {
  getLeftTaskCount,
  getTaskList,
  getTopTaskStatusCount,
  getTaskMsgTips,
  taskCount,
  getLeftTaskCountWithBuildingId,
  getTaskListWithBuildingId,
  getTopTaskStatusCountWithBuildingId,
  getLeftTaskCountWithOrg,
  getTaskListWithOrg,
  getTopTaskStatusCountWithOrg,
}